$.fn.actionDialog = function(title, width, height) {
	var id = $(this).attr("id");
	FUI.layuiLayer.open({
		type: 1,
		offset: '30px',
		maxmin: true,
		content: $('#' + id),
		area: [width, height],
		title: title
	});
};

//流程表单操作按钮
var ProcessFormUrl = "/workflow/workflowform/";
var workflowformSender = "/workflow/workflowformSender/";
//*****************阅式审批自动提交**********************************
$(function() {
	setTimeout(function() {
		if (WFContext.CurrentIsReadAutoApproval === true && WFContext.OutType == "Auto") {
			return sendWorkflow(window.myvm, {}, {});
		}
	}, 3000);

});

//*****************提交窗口，驳回窗口定义**********************************



function cancleSendWorkflow_ButtonClick() {
	FUI.layuiLayer.closeAll();
}

//发起流程时的传阅用户
var _circulatedTempUserJson = "";

function printTable(beforeFn) {
	if (!actionButtonBefore(beforeFn)) return false;
	var oleHieght = $("#WorkflowContentDiv").css("height");
	$("#WorkflowContentDiv").css("height", "auto");
	$("#wftoolbar").hide();
	print();
	$("#wftoolbar").show();
	setTimeout(function() {
		$("#WorkflowContentDiv").css("height", oleHieght);
	}, 800);
}

function printExcelTable(beforeFn, wfformId, wiid) {
	if (!actionButtonBefore(beforeFn)) return false;
	var url = __webpath + "/workflow/smartForm/onlineExcelView?wfformId=" + wfformId + "&wiid=" + wiid;
	FUI.Window.open(url, "_blank");
}

function showWorkflowMap(beforeFn) {
	if (!actionButtonBefore(beforeFn)) return false;
	var url = __webpath + "/workflow/flowDesigner/workflowMap/?wid=" + WFContext.WorkflowId + "&wiid=" + WFContext
		.WorkflowInstanceId;
	var title = "办理过程：" + WFContext.WorkflowName;
	var width = 1100;
	var height = 600;
	FUI.Window.openEdit(url, title, null, null, width, height, null, null, null, true);
}

function showWorkflowMapTimeline(beforeFn) {
	if (!actionButtonBefore(beforeFn)) return false;
	var url = __webpath + "/workflow/flowDesigner/workflowMapTimeline/?wid=" + WFContext.WorkflowId + "&wiid=" +
		WFContext.WorkflowInstanceId;
	var title = "办理过程：" + WFContext.WorkflowName;
	var width = 1100;
	var height = 600;
	FUI.Window.openEdit(url, title, null, null, width, height, null, null, null, true);
}
//查看办理过程
function showHistoryApproval(beforeFn) {
	if (!actionButtonBefore(beforeFn)) return false;
	var url = __webpath + "/workflow/workflowBusiness/showApprovalHistory/?wiid=" + WFContext.WorkflowInstanceId;
	var title = WFContext.WorkflowName + "-查看办理过程";
	var width = 780;
	var height = 460;
	FUI.Window.openEdit(url, title, null, null, width, height, null, null, null, false);
}

//查看传阅过程
function showCirculatedHistory(beforeFn) {
	if (!actionButtonBefore(beforeFn)) return false;
	var url = __webpath + "/workflow/workflowBusiness/showCirculatedHistory/?wiid=" + WFContext.WorkflowInstanceId;
	var title = WFContext.WorkflowName + "-查看传阅过程";
	var width = 780;
	var height = 460;
	FUI.Window.openEdit(url, title, null, null, width, height, null, null, null, false);

}

//互动留言过程
function showCommentRecordHistory(beforeFn) {
	if (!actionButtonBefore(beforeFn)) return false;
	var url = __webpath + "/workflow/pageRoute/showCommentRecord/?isShowDialog=1&wiid=" + WFContext.WorkflowInstanceId +
		"&isHistory=" + WFContext.IsHistory + "&formAction=" + WFContext.WorkflowformAction + "&activityName=" +
		WFContext.CurrentActivityName +
		"&appId=" + WFContext.AppId + "&openBizDate=" + WFContext.OpenBizDate + "&workflowId=" + WFContext.WorkflowId +
		"&realName=" + WFContext.RealName
	var title = WFContext.WorkflowName + "-流程评论";
	var width = 780;
	var height = 460;
	FUI.Window.openEdit(url, title, null, null, width, height, null, null, null, false);

}

//*****************打开窗口： 提交，保存，驳回 作废 等*****************
//打开提交窗口
function openSendDialog($vm, beforeFn, btnDef) {
	if (!actionButtonBefore(beforeFn)) return false;
	if (WFContext.OutType == "Manual") {

	}
	var WorkflowTitle = $vm.wfContext.WorkflowTitle
	// if (WorkflowTitle == "") {
	// 	FUI.Window.showMsg("流程标题不能为空！");
	// 	return false;
	// }
	// if (!FUI.validate("WorkflowformContainer")) {
	//     //FUI.layuiLayer.msg( "表单填写内容校验不通过，请检查是否有必填或数据类型填写是否正确！");
	// }
	//如果有审核菜单时必选
	if ($vm.approData && $vm.approData.length > 0 && $vm.approAction == '') {
		FUI.Window.showMsg("请选择审核菜单");
		return false;
	}
	//开启表单审批意见区时先校验是否必填意见
	var theFormOpinion = $vm.workflowformData.hidOpinion || "";
	if (WFContext.IsShowFormOpinion && WFContext.IsMustAddOpinion == true && theFormOpinion == "") {
		FUI.Window.showMsg(null, "请填写“审核意见”！");
		return false;
	}
	if (WFContext.OutType == "Manual") {
		//弹窗二次选择
		var width = 680;
		var height = 530;
		if (WFContext.IsShowFormOpinion) {
			height = 460;
		}
		FUI.dialog(FUI.Handlers.SendActor + "actorSelect?appId=" + $vm.wfContext.AppId + "&taskId=" + $vm.wfContext
			.TaskId +
			"&wiid=" + $vm.wfContext.WorkflowInstanceId + "&formAction=" + $vm.wfContext.WorkflowformAction,
			"提交选择处理人", {},
			width, height,
			function(data, index, layerObject) {
				if (data == false) {
					return false;
				}
				if (WFContext.IsShowFormOpinion) {
					//取表单处的意见
					data.hidOpinion = $vm.workflowformData.hidOpinion || "";
				}
				if (WFContext.IsMustAddOpinion == true && data.hidOpinion == "") {
					FUI.Window.showMsg(null, "请填写审核意见！");
					return false;
				}
				if (data.hidOpinion.length >= 1000) {
					FUI.Window.showMsg(null, "处理意见输入长度不能大于1000个字符！");
					return false;
				}
				//是否有自由传阅
				var tipmsg = "您确定提交到【" + data.selectedActivity + "】"
				var targetCirculatedActorValue = data.targetCirculatedActorValue;
				if (targetCirculatedActorValue) {
					tipmsg = tipmsg + ",并传阅到指定的用户";
				}
				FUI.Window.confirm($vm, tipmsg + "吗？", "温馨提示", function(index) {
					layer.close(index);
					return sendWorkflow($vm, data, btnDef);
				});
				//layerObject.close(index);
				return false;
			}, true, {
				fit: true,
				btnAlign: 'c',
				zIndex: 800
			}, {
				sure: {
					iconClass: "fa fa-share",
					text: "确定提交"
				},
				close: {
					iconClass: "fa  fa-minus-circle",
					text: "取消"
				}
			});
	} else if (WFContext.OutType == "Auto") {
		var data = {
			hidOpinion: theFormOpinion
		};
		if (WFContext.IsMustAddOpinion == true && data.hidOpinion == "") {
			FUI.Window.showMsg("请填写审核意见！");
			return false;
		}
		if (data.hidOpinion.length >= 1000) {
			FUI.Window.showMsg(null, "处理意见输入长度不能大于1000个字符！");
			return false;
		}
		//不需要弹窗口、不弹出选择人员对话框
		//如需填写审批意见需要在表单中加入审批意见的控件
		FUI.Window.confirm($vm, '您确定提交吗？', "提交确认", function() {
			return sendWorkflow($vm, data, btnDef);
		});
	}
	return false;
};

//点击驳回事件
function openRejectActorSelected($vm, beforeFn, btnDef) {
	if (!actionButtonBefore(beforeFn)) return false;
	var width = 680;
	var height = 520;
	if (WFContext.IsShowFormOpinion) {
		height = 380;
	}
	//开启表单审批意见区时先校验是否必填意见
	FUI.dialog(FUI.Handlers.SendActor + "actorRejectSelect?taskId=" + $vm.wfContext.TaskId + "&formAction=" + $vm
		.wfContext
		.WorkflowformAction, "选择驳回节点及处理人", {}, width, height,
		function(data, index, layerObject) {
			if (data == false) {
				return false;
			}
			if (data.hidOpinion == "") {
				FUI.Window.showMsg(null, "请填写驳回审核意见！");
				return false;
			}
			if (data.hidOpinion.length >= 1000) {
				FUI.Window.showMsg(null, "处理意见输入长度不能大于1000个字符！");
				return false;
			}
			//是否有自由传阅
			var tipmsg = "您确定驳回到【" + data.selectedActivity + "】"
			FUI.Window.confirm($vm, tipmsg + "吗？", "温馨提示", function(index) {
				layer.close(index);
				return rejectWorkflow($vm, data, btnDef);
			});
			//layerObject.close(index);
			return false;
		}, false, {
			fit: true,
			btnAlign: 'c',
			zIndex: 800
		}, {
			sure: {
				iconClass: "fa fa-share",
				text: "确定驳回"
			},
			close: {
				iconClass: "fa  fa-minus-circle",
				text: "取消"
			}
		});
}

//打开传阅窗口
function openCirculatedActor($vm, beforeFn) {
	try {
		//调用按钮前置函数
		if (!actionButtonBefore(beforeFn)) return false;

	} catch (err) {
		alert(err);
		return false;
	}
	var width = 680;
	var height = 520;
	if (WFContext.IsShowFormOpinion) {
		height = 380;
	}
	//开启表单审批意见区时先校验是否必填意见
	var theFormOpinion = $vm.workflowformData.hidOpinion || "";
	if (WFContext.IsShowFormOpinion && theFormOpinion == "") {
		FUI.Window.showMsg(null, "请填写“审核意见”！");
		return false;
	}
	FUI.dialog(FUI.Handlers.SendActor + "circulatedActorSelect?taskId=" + $vm.wfContext.TaskId + "&formAction=" + $vm
		.wfContext
		.WorkflowformAction, "提交到要传阅的用户", {}, width, height,
		function(data, index, layerObject) {
			if (data == false) {
				return false;
			}
			if (WFContext.IsShowFormOpinion) {
				//取表单处的意见
				data.hidOpinion = theFormOpinion;
			}
			if (WFContext.IsMustAddOpinion == true && data.hidOpinion == "") {
				FUI.Window.showMsg(null, "请填写意见！");
				return false;
			}
			if (data.hidOpinion.length >= 1000) {
				FUI.Window.showMsg(null, "意见输入长度不能大于1000个字符！");
				return false;
			}
			var typeName = "传阅";
			FUI.Window.confirm($vm, "您确定要" + typeName + "吗？", "温馨提示", function(index) {
				layer.close(index);
				return circulatedWorkflow($vm, data);
			});
			//layerObject.close(index);
			return false;
		}, false, {
			fit: true,
			btnAlign: 'c',
			zIndex: 800
		}, {
			sure: {
				iconClass: "fa fa-share",
				text: "确定传阅"
			},
			close: {
				iconClass: "fa  fa-minus-circle",
				text: "取消"
			}
		});
	return false;

}

//打开转交窗口
function openReferredActor($vm, beforeFn) {
	try {
		//调用按钮前置函数
		if (!actionButtonBefore(beforeFn)) return false;

	} catch (err) {
		alert(err);
		return false;
	}
	var width = 680;
	var height = 520;
	if (WFContext.IsShowFormOpinion) {
		height = 380;
	}
	//开启表单审批意见区时先校验是否必填意见
	var theFormOpinion = $vm.workflowformData.hidOpinion || "";
	if (WFContext.IsShowFormOpinion && theFormOpinion == "") {
		FUI.Window.showMsg(null, "请填写“意见”！");
		return false;
	}
	FUI.dialog(FUI.Handlers.SendActor + "assistActorSelect?taskId=" + $vm.wfContext.TaskId + "&formAction=" + $vm
		.wfContext
		.WorkflowformAction, "选择转办到用户", {}, width, height,
		function(data, index, layerObject) {
			if (data == false) {
				return false;
			}
			if (WFContext.IsShowFormOpinion) {
				//取表单处的意见
				data.hidOpinion = theFormOpinion;
			}
			if (WFContext.IsMustAddOpinion == true && data.hidOpinion == "") {
				FUI.Window.showMsg(null, "请填写意见！");
				return false;
			}
			if (data.hidOpinion.length >= 1000) {
				FUI.Window.showMsg(null, "意见输入长度不能大于1000个字符！");
				return false;
			}
			var typeName = "转办";
			FUI.Window.confirm($vm, "您确定要" + typeName + "吗？", "温馨提示", function(index) {
				layer.close(index);
				return referredWorkflow($vm, data);
			});
			//layerObject.close(index);
			return false;
		}, false, {
			fit: true,
			btnAlign: 'c',
			zIndex: 800
		}, {
			sure: {
				iconClass: "fa fa-share",
				text: "确定转办"
			},
			close: {
				iconClass: "fa  fa-minus-circle",
				text: "取消"
			}
		});
	return false;

}

function sendWorkflow($vm, data, btnDef) {
	//如果是Url表单，调用Url表单
	if (WFContext.FormType == 'UrlForm') {
		submitUrlFormMethod($vm, btnDef, "sendWorkflow", function(resultMsg, billNo){
			if (typeof resultMsg == "boolean" && resultMsg === false) {
				return false;
			} else if (typeof resultMsg == "string" && resultMsg != "") {
				FUI.Window.showMsg(resultMsg);
				return false;
			}
			var dataJsonParm = {};
			dataJsonParm.formAction = WFContext.WorkflowformAction;
			dataJsonParm.formId = WFContext.FormId;
			dataJsonParm.businessKey = billNo ? billNo : WFContext.BusinessKey;
			dataJsonParm.wiid = WFContext.WorkflowInstanceId;
			dataJsonParm.wid = WFContext.WorkflowId;
			dataJsonParm.appId = WFContext.AppId;
			dataJsonParm.taskId = WFContext.TaskId;
			dataJsonParm.circulatedUserJson = data.targetCirculatedActorValue || "";
			dataJsonParm.approAction = "";
			//选择的处理人结果及处理意见
			dataJsonParm.hidOpinion = data.hidOpinion;
			dataJsonParm.hidSelectUsers = data.hidSelectUsers;
			dataJsonParm.hidSelectedActivityType = data.hidSelectedActivityType;
			dataJsonParm.hidSelectedActivityJson = data.hidSelectedActivityJson;
			
			//下一节点为自定义流时
			dataJsonParm.nextActIsFreeflow = WFContext.NextActIsFreeflow;
			dataJsonParm.nextActIsFreeflowJson = data.nextActIsFreeflowJson || "";
			WF.Workflowform.submitWorkflowform($vm, workflowformSender, "sendWorkflow", null, dataJsonParm, null, null,
				function(
					mssg) {
					if (mssg === false) return false;
					if (mssg.success) {
						if (window.opener != null) {
							try {
								//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
								if (typeof customRefreshOpenerWindow == "function") {
									customRefreshOpenerWindow.call(this);
								} else {
									//转到待办页面
									//
									//window.opener.window.refreshTargetGrid("grid");
								}
							} catch (err) {}
						}
						if (WFContext.CurrentIsReadAutoApproval === true) {
							//阅式自动审批时跳转到工单查看页面
							window.location.href = __webpath + "/workflow/workflowform?appId=" + WFContext.AppId +
								"&formAction=3&wiid=" +
								WFContext.WorkflowInstanceId;
						} else {
							FUI.Window.showMsg(mssg.msg, "提交成功", "info", function() {
								if (window.opener != null) {
									window.close();
								} else {
									FUI.Window.closeEditAll();
									//window.parent.FUI.Window.ngto(__webpath + "/workflow/businessMP/todoList", true);
									uni.reLaunch({
										url: '/workspaces/views/order'
									});
								}
							});
						}
					} else {
						FUI.Window.showMsg(mssg.msg);
					}
				});
			return false;
		});
	} else {
		var dataJsonParm = {};
		dataJsonParm.formAction = WFContext.WorkflowformAction;
		dataJsonParm.formId = WFContext.FormId;
		dataJsonParm.businessKey = WFContext.BusinessKey;
		dataJsonParm.wiid = WFContext.WorkflowInstanceId;
		dataJsonParm.wid = WFContext.WorkflowId;
		dataJsonParm.appId = WFContext.AppId;
		dataJsonParm.taskId = WFContext.TaskId;
		dataJsonParm.circulatedUserJson = data.targetCirculatedActorValue || "";
		dataJsonParm.approAction = "";
		//选择的处理人结果及处理意见
		dataJsonParm.hidOpinion = data.hidOpinion;
		dataJsonParm.hidSelectUsers = data.hidSelectUsers;
		dataJsonParm.hidSelectedActivityType = data.hidSelectedActivityType;
		dataJsonParm.hidSelectedActivityJson = data.hidSelectedActivityJson;
		
		//下一节点为自定义流时
		dataJsonParm.nextActIsFreeflow = WFContext.NextActIsFreeflow;
		dataJsonParm.nextActIsFreeflowJson = data.nextActIsFreeflowJson || "";
		WF.Workflowform.submitWorkflowform($vm, workflowformSender, "sendWorkflow", null, dataJsonParm, null, null,
			function(
				mssg) {
				if (mssg === false) return false;
				if (mssg.success) {
					if (window.opener != null) {
						try {
							//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
							if (typeof customRefreshOpenerWindow == "function") {
								customRefreshOpenerWindow.call(this);
							} else {
								//转到待办页面
								//
								//window.opener.window.refreshTargetGrid("grid");
							}
						} catch (err) {}
					}
					if (WFContext.CurrentIsReadAutoApproval === true) {
						//阅式自动审批时跳转到工单查看页面
						window.location.href = __webpath + "/workflow/workflowform?appId=" + WFContext.AppId +
							"&formAction=3&wiid=" +
							WFContext.WorkflowInstanceId;
					} else {
						FUI.Window.showMsg(mssg.msg, "提交成功", "info", function() {
							if (window.opener != null) {
								window.close();
							} else {
								FUI.Window.closeEditAll();
								//window.parent.FUI.Window.ngto(__webpath + "/workflow/businessMP/todoList", true);
								uni.reLaunch({
									url: '/workspaces/views/order'
								});
							}
						});
					}
				} else {
					FUI.Window.showMsg(mssg.msg);
				}
			});
		return false;
	}
}

//驳回
function rejectWorkflow($vm, data, btnDef) {
	//如果是Url表单，调用Url表单
	if (WFContext.FormType == 'UrlForm') {
		let resultMsg = submitUrlFormMethod($vm, btnDef, "rejectWorkflow")
		if (typeof resultMsg == "boolean" && resultMsg === false) {
			return false;
		} else if (typeof resultMsg == "string" && resultMsg != "") {
			FUI.Window.showMsg(resultMsg);
			return false;
		}
	}
	var dataJsonParm = {};
	dataJsonParm.formAction = WFContext.WorkflowformAction;
	dataJsonParm.wiid = WFContext.WorkflowInstanceId;
	dataJsonParm.formId = WFContext.FormId;
	dataJsonParm.wid = WFContext.WorkflowId;
	dataJsonParm.appId = WFContext.AppId;
	dataJsonParm.taskId = WFContext.TaskId;
	dataJsonParm.OutType = WFContext.OutType;
	//选择的结果及处理意见
	dataJsonParm.hidOpinion = data.hidOpinion;
	dataJsonParm.hidSelectUsers = data.hidSelectUsers;
	dataJsonParm.hidSelectedActivityType = data.hidSelectedActivityType;
	dataJsonParm.hidSelectedActivityJson = data.hidSelectedActivityJson;
	dataJsonParm.rejectBackType = data.rejectBackType || "";
	var isRejectToMain = data.isRejectToMain;
	var method = isRejectToMain ? "rejectToMainWorkflow" : "rejectWorkflow";
	WF.Workflowform.submitWorkflowform($vm, workflowformSender, method, null, dataJsonParm, null, null,
	function(mssg) {
		Object.toCloseLoading();
		if (mssg === false) return false;
		if (mssg.success) {
			if (window.opener != null) {
				try {
					//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
					if (typeof customRefreshOpenerWindow == "function") {
						customRefreshOpenerWindow.call(this);
					} else {
						window.opener.window.refreshTargetGrid("grid");

					}
				} catch (err) {}

			}
			FUI.Window.showMsg(mssg.msg, "驳回提示", "info", function() {
				FUI.Window.closeEditAll();
				//window.parent.FUI.Window.ngto(__webpath + "/workflow/businessMP/todoList", true);
				uni.reLaunch({
					url: '/workspaces/views/order'
				});
			});

		} else {
			FUI.Window.showMsg(mssg.msg);
			if (window.opener != null) {
				try {
					//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
					if (typeof customRefreshOpenerWindow == "function") {
						customRefreshOpenerWindow.call(this);

					} else {
						FUI.Window.closeEditAll();
						//window.parent.FUI.Window.ngto(__webpath + "/workflow/businessMP/todoList", true);
						uni.reLaunch({
							url: '/workspaces/views/order'
						});

					}
				} catch (err) {}

			}
		}

	}, false);
	return false;
}

//传阅
function circulatedWorkflow($vm, data) {
	var dataJsonParm = {};
	dataJsonParm.formAction = WFContext.WorkflowformAction;
	dataJsonParm.wiid = WFContext.WorkflowInstanceId;
	dataJsonParm.formId = WFContext.FormId
	dataJsonParm.wid = WFContext.WorkflowId;
	dataJsonParm.appId = WFContext.AppId;
	dataJsonParm.taskId = WFContext.TaskId;
	dataJsonParm.OutType = WFContext.OutType;

	//选择的结果及处理意见
	dataJsonParm.hidOpinion = data.hidOpinion;
	dataJsonParm.hidSelectUsers = data.hidSelectUsers;
	if (dataJsonParm.hidOpinion.length >= 1000) {
		FUI.Window.showMsg("审核意见输入长度不能大于1000个字符！");
		return false;
	}
	var mssg = Object.toAjaxJson(workflowformSender, "sendCirculatedWorkflow", dataJsonParm);
	if (mssg === false) return false;
	if (mssg.success) {
		FUI.Window.showMsg(mssg.msg, "温馨提示", "info", function() {
			FUI.Window.closeEditAll();
		});
	} else {
		FUI.Window.showMsg(mssg.msg);
		FUI.Window.closeEditAll();
	}
	return false;

}

//转交
function referredWorkflow($vm, data) {
	var dataJsonParm = {};
	dataJsonParm.formAction = WFContext.WorkflowformAction;
	dataJsonParm.wiid = WFContext.WorkflowInstanceId;
	dataJsonParm.formId = WFContext.FormId
	dataJsonParm.wid = WFContext.WorkflowId;
	dataJsonParm.appId = WFContext.AppId;
	dataJsonParm.taskId = WFContext.TaskId;
	dataJsonParm.OutType = WFContext.OutType;

	//选择的结果及处理意见
	dataJsonParm.hidOpinion = data.hidOpinion;
	dataJsonParm.hidSelectUsers = data.hidSelectUsers;
	if (dataJsonParm.hidOpinion.length >= 1000) {
		FUI.Window.showMsg("审核意见输入长度不能大于1000个字符！");
		return false;
	}
	var mssg = Object.toAjaxJson(workflowformSender, "sendReferredWorkflow", dataJsonParm);
	Object.toCloseLoading();
	if (mssg === false) return false;
	if (mssg.success) {
		if (window.opener != null) {
			try {
				//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
				if (typeof customRefreshOpenerWindow == "function") {
					customRefreshOpenerWindow.call(this);

				} else {
					window.opener.window.refreshTargetGrid("grid");

				}
			} catch (err) {}

		}
		FUI.Window.showMsg(mssg.msg, "转办成功", "info", function() {
			if (window.opener != null) {
				window.close();
			} else {
				FUI.Window.closeEditAll();
				//window.parent.FUI.Window.ngto(__webpath + "/workflow/businessMP/todoList", true);
				uni.reLaunch({
					url: '/workspaces/views/order'
				});
			}
		});
	} else {
		FUI.Window.showMsg(mssg.msg);
	}
	return false;

}

function actionButtonBefore(beforeFn) {
	try {
		var isCando = true;
		if (beforeFn) {
			if (typeof eval(beforeFn) == "function") {
				isCando = eval(beforeFn).call(this);
			}
		}
		return isCando;
	} catch (err) {
		alert(err);
		return false;
	}
}

//暂存表单
function saveWorkflow($vm, isAutoSave, beforeFn, btnDef) {
	if (isAutoSave == false) {
		if (!actionButtonBefore(beforeFn)) return false;
		//调用固有的前置函数（在线表单或用户表单中有此函数时都触发调用）
		if (typeof $fixedFormSubmitBefore == "function") {
			var beforSaveMsg = $fixedFormSubmitBefore();
			if (beforSaveMsg != "") {
				FUI.layuiLayer.msg(beforSaveMsg);
				return false;
			}
		}
		saveWorkflowSubmit($vm, isAutoSave, btnDef);

	} else {
		saveWorkflowSubmit($vm, isAutoSave, btnDef);
	}
	return false;
}
//调用iframe的Url表单函数
window.submitUrlFormMethod = function($vm, btnDef, methodName, callback) {
	var cubmitResult = "";
	var frameWindow = window["urlFormIframe"].contentWindow;
	var url = $("#urlFormIframe").attr("src");
	if (url == null || url == "" || (url.indexOf("{") > -1 && url.indexOf("}") > -1)) {
		//配置的是JSON结构，直接返回
		return true;
	}
	if ((Object.toStartWith(url, "http") || Object.toStartWith(url, "https")) && WFContext.IsEnabledHttpform !== true) {
		console.info("使用的是外部URL表单并且配置了isEnabledHttpform为false,所以不发触与iframe交互");
		return true;
	}
	var $urlFormVue = frameWindow.$urlFormVue;
	if ($urlFormVue) {
		$urlFormVue[methodName](btnDef,function(result, billNo){
			callback(result, billNo)
		});
	} else if ($urlFormVue == undefined) {
		cubmitResult = frameWindow[methodName](btnDef);
		return cubmitResult;
	}
};
//保存流程
function saveWorkflowSubmit ($vm, isAutoSave, btnDef) {
	if (WFContext.FormType == 'UrlForm') {
		//Url表单时
		submitUrlFormMethod($vm, btnDef, "saveWorkflow", function(resultMsg, billNo){
			if (typeof resultMsg == "boolean" && resultMsg === false) {
				return false;
			} else if (typeof resultMsg == "string" && resultMsg != "") {
				FUI.Window.showMsg(resultMsg);
				return false;
			} else if(typeof resultMsg == "undefined"){
				return false;
			}
			//保存 先保存工作流，再保存表单，如果是未有实例的情况下保存为草稿，且保存完跳转页面
			var dataJsonParm = {};
			dataJsonParm.businessKey = billNo ? billNo : WFContext.BusinessKey;;
			dataJsonParm.formAction = WFContext.WorkflowformAction;
			dataJsonParm.wiid = WFContext.WorkflowInstanceId;
			dataJsonParm.formId = WFContext.FormId
			dataJsonParm.wid = WFContext.WorkflowId;
			dataJsonParm.appId = WFContext.AppId;
			dataJsonParm.taskId = WFContext.TaskId;
			
			WF.Workflowform.submitWorkflowform($vm, workflowformSender, "saveWorkflow", null, dataJsonParm, null, null,
				function(
					mssg) {
					Object.toCloseLoading();
					if (mssg === false) return false;
					if (mssg.success) {
						if (window.opener != null) {
							try {
								//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
								if (typeof customRefreshOpenerWindow == "function") {
									customRefreshOpenerWindow.call(this);
			
								} else {
									window.opener.window.refreshTargetGrid("grid");
			
								}
							} catch (err) {}
			
						}
						if (WFContext.WorkflowformAction == WF.WorkflowformAction.NoInstance) {
							FUI.Window.showMsg2(null, mssg.msg, null, 1);
							//拟稿保存后跳转到草稿模式
							/* var url = __webpath + "/workflow/businessMP/workflowform?appId=" + WFContext.AppId +
								"&formAction=2&wiid=" +
								WFContext.WorkflowInstanceId + "&taskId=" + WFContext.TaskId;
							FUI.Window.ngto(url, true) */
						} else {
							FUI.Window.showMsg2(mssg.msg, null, 1);
							//window.location.reload();
						}
						uni.setStorageSync("currentIndex", 3);
						uni.reLaunch({
							url: '/workspaces/views/order'
						});
					} else {
						FUI.Window.showMsg(mssg.msg);
					}
				}, true);
			return false;
		});
	} else {
		//保存 先保存工作流，再保存表单，如果是未有实例的情况下保存为草稿，且保存完跳转页面
		var dataJsonParm = {};
		dataJsonParm.formAction = WFContext.WorkflowformAction;
		dataJsonParm.wiid = WFContext.WorkflowInstanceId;
		dataJsonParm.formId = WFContext.FormId
		dataJsonParm.wid = WFContext.WorkflowId;
		dataJsonParm.appId = WFContext.AppId;
		dataJsonParm.taskId = WFContext.TaskId;

		WF.Workflowform.submitWorkflowform($vm, workflowformSender, "saveWorkflow", null, dataJsonParm, null, null,
			function(
				mssg) {
				Object.toCloseLoading();
				if (mssg === false) return false;
				if (mssg.success) {
					if (window.opener != null) {
						try {
							//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
							if (typeof customRefreshOpenerWindow == "function") {
								customRefreshOpenerWindow.call(this);

							} else {
								window.opener.window.refreshTargetGrid("grid");

							}
						} catch (err) {}

					}
					if (WFContext.WorkflowformAction == WF.WorkflowformAction.NoInstance) {
						FUI.Window.showMsg2(null, mssg.msg, null, 1);
						//拟稿保存后跳转到草稿模式
						/* var url = __webpath + "/workflow/businessMP/workflowform?appId=" + WFContext.AppId +
							"&formAction=2&wiid=" +
							WFContext.WorkflowInstanceId + "&taskId=" + WFContext.TaskId;
						FUI.Window.ngto(url, true) */
					} else {
						FUI.Window.showMsg2(mssg.msg, null, 1);
						//window.location.reload();
					}
					uni.setStorageSync("currentIndex", 3);
					uni.reLaunch({
						url: '/workspaces/views/order'
					});
				} else {
					FUI.Window.showMsg(mssg.msg);
				}
			}, true);
		return false;
	}
};

function saveNoWorkflowfrom(isAutoSave, beforeFn) {
	if (isAutoSave == false) {
		if (!actionButtonBefore(beforeFn)) return false;
		//调用固有的前置函数（在线表单或用户表单中有此函数时都触发调用）
		if (typeof $fixedFormSubmitBefore == "function") {
			var beforSaveMsg = $fixedFormSubmitBefore();
			if (beforSaveMsg != "") {
				FUI.layuiLayer.msg(beforSaveMsg);
				return false;
			}
		}
		FUI.Window.confirm("确定要保存吗？", "温馨提示", function(r) {
			if (r) {
				saveNoWorkflowSubmit(isAutoSave);
			} else {
				//取消点击
			}
		});
	} else {
		saveNoWorkflowSubmit(isAutoSave);
	}
	return false;
}

//saveNoWorkflowCallSubmit(callBack) 使用自己的按钮代码调用保存无流程表单。传入回调函数callBack返回{success:true/false,msg:"错误信息"}
function saveNoWorkflowCallSubmit(callBack) {
	if (typeof callBack != "function" && callBack) {
		callBack = eval(callBack);
	}
	var dataJsonParm = {};
	dataJsonParm.formAction = WFContext.WorkflowformAction;
	dataJsonParm.formId = WFContext.FormId;
	dataJsonParm.formKey = WFContext.FormKey;
	dataJsonParm.businessKey = WFContext.BusinessKey;
	WF.Workflowform.submitWorkflowform(__webpath + "/workflow/noWorkflowform/", "saveNoWorkflow", null, dataJsonParm,
		null,
		null, callBack, true);
	return false;
};

//保存无流程表单
function saveNoWorkflowSubmit(isAutoSave) {
	var dataJsonParm = {};
	dataJsonParm.formAction = WFContext.WorkflowformAction;
	dataJsonParm.formId = WFContext.FormId;
	dataJsonParm.formKey = WFContext.FormKey;
	dataJsonParm.businessKey = WFContext.BusinessKey;
	WF.Workflowform.submitWorkflowform(__webpath + "/workflow/noWorkflowform/", "saveNoWorkflow", null, dataJsonParm,
		null,
		null,
		function(mssg) {
			Object.toCloseLoading();
			if (mssg === false) return false;
			if (mssg.success) {

				if (window.parent != null) {
					try {
						//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
						if (typeof customRefreshOpenerWindow == "function") {
							customRefreshOpenerWindow.call(this);
						} else {
							//alert(1);
							window.parent.refreshTargetGrid("grid");
						}
					} catch (err) {

					}
				}
				if (WFContext.WorkflowformAction == WF.WorkflowformAction.NoInstance) {
					FUI.Window.showLeftBelowMsg(mssg.msg);
					//拟稿保存后跳转到草稿模式
					window.location = __webpath + "/workflow/noWorkflowform/index/?formId=" + WFContext.FormId +
						"&formAction=2&businessKey=" + WFContext.BusinessKey;
				} else {
					FUI.Window.showMsg(mssg.msg, null, 1);
					window.location = window.location;
				}
			} else {
				FUI.Window.showMsg(mssg.msg);
			}
		}, true);
	return false;
};

//设置已阅
function setDoneCirculated($vm, beforeFn) {
	try {
		//调用按钮前置函数
		if (!actionButtonBefore(beforeFn)) return false;
	} catch (err) {
		alert(err);
		return false;
	}
	FUI.Window.confirm("确定要标记为已阅吗？", "温馨提示", function(index) {
		try {
			var dataJsonParm = {};
			dataJsonParm.formAction = WFContext.WorkflowformAction;
			dataJsonParm.wiid = WFContext.WorkflowInstanceId;
			dataJsonParm.formId = WFContext.FormId
			dataJsonParm.wid = WFContext.WorkflowId;
			dataJsonParm.appId = WFContext.AppId;
			dataJsonParm.taskId = WFContext.TaskId;
			var mssg = Object.toAjaxJson(workflowformSender, "setDoneCirculated", dataJsonParm);
			if (mssg === false) return false;
			if (mssg.success) {
				if (window.opener != null) {
					try {
						//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
						if (typeof customRefreshOpenerWindow == "function") {
							customRefreshOpenerWindow.call(this);

						} else {
							window.opener.window.refreshTargetGrid("grid");

						}
					} catch (err) {}

				}
				FUI.Window.showMsg(mssg.msg, "提示", "info", function() {
					if (window.opener != null) {
						window.close();
					} else {
						window.parent.FUI.Window.ngto(__webpath +
							"/workflow/businessMP/todoCirculatedList", true);

					}

				});

			} else {
				FUI.Window.showMsg(mssg.msg, null, 1);
			}
			return false;

		} catch (err) {
			FUI.Window.showMsg(err);
			return false;
		}

	});

	return false;
};

//锁定
function taskclaim($vm, beforeFn) {
	if (!actionButtonBefore(beforeFn)) return false;
	var isUnClaim = WFContext.TaskState == 3 ? 1 : 0;
	var title = isUnClaim == 1 ? "解除锁定？" : "锁定任务？";
	FUI.Window.confirm($vm, "您确定要" + title, null, function(r) {
		var mssg = Object.toAjaxJson(workflowformSender, "taskclaim", {
			taskId: WFContext.TaskId,
			isUnClaim: isUnClaim
		});
		if (mssg.success) {
			WFContext.TaskState = WFContext.TaskState == 3 ? 1 : 3;
			FUI.Window.showMsg(null, mssg.msg, null, "info", function() {
				//修改按钮样式
				var target = $("#taskclaim");
				if (WFContext.TaskState == 3) {
					target.find("span").find("i").addClass("fa-lock");
					target.find("span").find("i").removeClass("fa-unlock");
					target.find("span").find("span").text("解除锁定");
				} else {
					target.find("span").find("i").addClass("fa-unlock");
					target.find("span").find("i").removeClass("fa-lock");
					target.find("span").find("span").text("锁定任务");
				}
			});
		}
	});
	return false;
};

//作废流程
function invalidWorkflow($vm) {
	FUI.Window.showModalMsg($vm, "", "作废流程", null, {
			sureText: '确定作废',
			label: '请输入作废流程的意见原因',
			tip: '请输入作废流程的意见原因',
			width: 500,
			height: 330
		},
		function(content, index, layerObject) {
			if (content) {
				try {
					var opinion = content;
					var dataJsonParm = {};
					dataJsonParm.formAction = WFContext.WorkflowformAction;
					dataJsonParm.wiid = WFContext.WorkflowInstanceId;
					dataJsonParm.formId = WFContext.FormId
					dataJsonParm.wid = WFContext.WorkflowId;
					dataJsonParm.appId = WFContext.AppId;
					dataJsonParm.taskId = WFContext.TaskId;
					dataJsonParm.OutType = WFContext.OutType;
					dataJsonParm.Opinion = opinion;
					//Object.toShowLoading();
					Object.toAjaxJson(workflowformSender, "invalidWorkflow", dataJsonParm, true, null, function(mssg) {
						if (mssg === false) return false;
						if (mssg.success) {
							if (window.opener != null) {
								try {
									//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
									if (typeof customRefreshOpenerWindow == "function") {
										customRefreshOpenerWindow.call(this);
									} else {
										window.opener.window.refreshTargetGrid("grid");
									}
								} catch (err) {}
							}

							FUI.Window.showMsg(null, mssg.msg, "流程实例作废提示", "info", function() {
								if (window.opener != null) {
									window.close();
								} else {
									FUI.Window.closeEditAll();
									//window.parent.FUI.Window.ngto(__webpath + "/workflow/businessMP/todoList",true);
									uni.reLaunch({
										url: '/workspaces/views/order'
									});
								}
							});

						} else {
							FUI.Window.showMsg(null, mssg.msg);
						}
					});

					return false;

				} catch (err) {
					FUI.Window.showMsg(null, err);
					return false;
				}
			} else {
				FUI.Window.showMsg(null, "请输入作废原因");
			}
		});
	return false;
};

//撤回任务
function withdrawWorkflow(beforeFn) {
	if (!actionButtonBefore(beforeFn)) return false;

	$.messager.prompt('确认窗口', '您确定要撤回此工单吗,请输入撤回原因？', function(r) {
		if (r) {
			try {
				var opinion = r;
				var dataJsonParm = {};
				dataJsonParm.formAction = WFContext.WorkflowformAction;
				dataJsonParm.wiid = WFContext.WorkflowInstanceId;
				dataJsonParm.formId = WFContext.FormId
				dataJsonParm.wid = WFContext.WorkflowId;
				dataJsonParm.appId = WFContext.AppId;
				dataJsonParm.taskId = WFContext.TaskId;
				dataJsonParm.OutType = WFContext.OutType;
				dataJsonParm.Opinion = opinion;
				var mssg = Object.toAjaxJson(workflowformSender, "withdrawWorkflow", dataJsonParm);
				if (mssg === false) return false;
				if (mssg.success) {
					if (window.opener != null) {
						try {
							//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
							if (typeof customRefreshOpenerWindow == "function") {
								customRefreshOpenerWindow.call(this);
							} else {
								window.opener.window.refreshTargetGrid("grid");
							}
						} catch (err) {}

					}
					FUI.Window.showMsg(mssg.msg, "流程撤回提示", "info", function() {
						if (window.opener != null) {
							window.close();
						} else {
							FUI.Window.closeEdit(true, 'grid');
						}
					});

				} else {
					FUI.Window.showMsg(mssg.msg);
				}
				return false;

			} catch (err) {
				FUI.Window.showMsg(err);
				return false;
			}
		} else {
			FUI.Window.showMsg("请输入撤回原因");
		}

	});
	return false;
};
//****************加盖印章**********************************
var $officialDocumentId = null;
$(function() {
	// initailStamp();
	// if($paget_initail_sealedJson&&$paget_initail_sealedJson.length>0){
	// 	$("#hidSeal").val(JSON.stringify($paget_initail_sealedJson));
	// }
	// !$officialDocumentId.startsWith("richeditor_") &&
	// if ($officialDocumentId != null && $("#" + $officialDocumentId).get(0).tagName != "TEXTAREA") {
	//     //     //只要是富文框 就不加载已盖好的印章，放在富文本框不可编辑时解析成Html时加载
	//     //     setTimeout(function () {  loadStamp($officialDocumentId);}, 500);
	//     // }

});

function initailStamp() {
	$officialDocumentId = "mainWorkformContainer";
	if ($("#officialDocument").length > 0) {
		$officialDocumentId = "officialDocument";
	} else if ($("textarea[richeditorType='richeditorofficial']").length > 0) {
		//是否是 HTML公文编辑器  原始控制
		$officialDocumentId = $("textarea[richeditorType='richeditorofficial']").attr("richeditorId");
	}
}

function openSealSelected() {

	WF.SelectorDialog.selectPersonalSeal({
		callBack: sealSign,
		isMulti: false,
		title: "选择要加盖的印章"
	});
	return false;
}

var $sealArr = [];

function sealSign(data) {
	var imgpath = data[0].sealPhotoFullPaht;
	if (imgpath.length < 2000 && imgpath.indexOf("http://") == -1 && Object.toStartWith(imgpath, __webpath) == false) {
		imgpath = __webpath + imgpath;
	}
	if (imgpath.length > 2000) {
		imgpath = "data:image/png;base64," + imgpath;
	}
	var sealId = data[0].sealId;
	var width = data[0].sealWidth;
	var height = data[0].sealHeight;
	var seal = FUI.SealSign.create($officialDocumentId, imgpath, sealId, null, null, sureStamp, {
		width: width,
		height: height
	});
	if (seal != null) {
		seal.bind();
		$sealArr.push(seal);
	}

	// seal.signSeal()
}

function sureStamp(obj) {
	// SealId: sealId, SealImgpath: options.img, StampHeight: options.height, StampWidth: options.width, PositionY: parseInt(sign.css('top')), PositionX: parseInt(sign.css('left')) 
	var sealJson = $("#hidSeal").val();
	var data = [];
	if (sealJson == "") {
		data.push(obj);
	} else {
		data = eval("(" + sealJson + ")");
		data.push(obj);
	}
	$("#hidSeal").val(JSON.stringify(data));
	console.info($("#hidSeal").val());
	//alert("img:" + obj.SealImgpath + ",left:" + obj.PositionX + ",top:" + obj.PositionY);
}

function loadStamp(targetOfficialDocumentId) {
	if ($("#" + targetOfficialDocumentId).length == 0) {
		return false;
	}
	var sealJson = $("#hidSeal").val();
	if (!sealJson || sealJson == "") return false;
	var data = eval("(" + sealJson + ")");
	var seal = FUI.SealSign.create(targetOfficialDocumentId);
	if (seal != null) {
		seal.load(data);
	}
}


//****************任务分发窗口 **********************************
//打开处理分发历史处理过程窗口
function showHistoryTaskdister() {
	var taskDisterWindowUrl = __webpath + "/workflow/userControls/showHistoryTaskdisterDailog/?type=taskdister&wiid=" +
		Object.toQueryString("wiid") + "&aiid=" + WFContext.CurrentActivityInstanceId;
	FUI.Window.openEdit(taskDisterWindowUrl, "查看任务分发过程", "View", null, 860, 560);
	return false;
}

//打开发分窗口
function openSendTaskdister(thisBtn) {
	//传递用户参数格式
	var parms = $collectParmsUsers(); // [{"value":"admin","text":"系统管理员"},{"value":"admintest","text":"test"}];
	var taskDisterWindowUrl = __webpath + "/workflow/workflowformSender/taskdisterSelect/?type=taskdister&wiid=" +
		Object.toQueryString(
			"wiid") + "&taskId=" + Object.toQueryString("taskId");
	FUI.Window.openEdit(taskDisterWindowUrl, "任务分发", "Edit", null, 860, 560, null, null, null, false, null, parms);
	return false;
}


//打开处理分发任务窗口
function openSendTaskdisterDailog() {
	var taskDisterWindowUrl = __webpath + "/workflow/workflowformSender/openSendTaskdisterDailog/?wiid=" + Object
		.toQueryString(
			"wiid") + "&taskId=" + Object.toQueryString("taskId");
	var parm = {};
	FUI.dialog(taskDisterWindowUrl, "提交并完成分发的任务", parm, 600, 400, function(objectData, dialog) {
		var opinion = objectData;
		if (opinion == "") {
			FUI.Window.showMsg("请填写处理意见");
		} else {
			$.messager.confirm('提交确认', "您确定提交吗？", function(r) {
				if (r) {
					saveTaskdisterSubmit(opinion);
				}
			});
			//dialog.dialog('destroy');
		}
		return false;
	}, false);
	return false;
}

function saveTaskdisterSubmit(opinion) {
	//保存 先保存工作流，再保存表单，如果是未有实例的情况下保存为草稿，且保存完跳转页面
	var dataJsonParm = {};
	dataJsonParm.formAction = WFContext.WorkflowformAction;
	dataJsonParm.wiid = WFContext.WorkflowInstanceId;
	dataJsonParm.formId = WFContext.FormId
	dataJsonParm.wid = WFContext.WorkflowId;
	dataJsonParm.appId = WFContext.AppId;
	dataJsonParm.taskId = WFContext.TaskId;
	dataJsonParm.opinion = opinion;
	WF.Workflowform.submitWorkflowform(workflowformSender, "sendCompletedTaskdisterTask", null, dataJsonParm, null,
		null,
		function(mssg) {
			Object.toCloseLoading();
			if (mssg === false) return false;
			if (mssg.success) {
				if (window.opener != null) {
					try {
						//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
						if (typeof customRefreshOpenerWindow == "function") {
							customRefreshOpenerWindow.call(this);

						} else {
							window.opener.window.refreshTargetGrid("grid");

						}
					} catch (err) {}

				}
				if (WFContext.WorkflowformAction == WF.WorkflowformAction.NoInstance) {
					FUI.Window.showLeftBelowMsg(mssg.msg, null, 1);
					//拟稿保存后跳转到草稿模式
					window.location = __webpath + "/workflow/workflowform/index/?appId=" + WFContext.AppId +
						"&formAction=2&wiid=" +
						WFContext.WorkflowInstanceId + "&taskId=" + WFContext.TaskId;
				} else {
					FUI.Window.showMsg(mssg.msg, null, 1);
					window.location = window.location;
				}
			} else {

				alert(mssg.msg);
			}
		});
	return false;
};

//**************************************************

//****************沟通传递窗口 **********************************
//打开沟通记录列表
function showHistoryTaskCommunication() {
	var taskDisterWindowUrl = __webpath +
		"/workflow/sendActor/showHistoryTaskdisterDailog/?type=taskCommunication&wiid=" +
		Object.toQueryString("wiid") + "&aiid=" + WFContext.CurrentActivityInstanceId;
	FUI.Window.openEdit(taskDisterWindowUrl, "查看传递沟通过程", "View", null, 900, 500, null, null, null, false);
	return false;
}

//打开沟通窗口
function openSendNextTaskCommunication($vm, beforeFunName) {
	var taskDisterWindowUrl = __webpath + "/workflow/sendActor/taskdisterSelect/?type=taskCommunication&wiid=" + Object
		.toQueryString(
			"wiid") + "&taskId=" + Object.toQueryString("taskId");
	FUI.Window.openEdit(taskDisterWindowUrl, "任务传递沟通", "Edit", null, 900, 500, null, null, null, false);
	return false;
}

//完成沟通
function openComplateTaskCommunicationDialog() {
	var url = __webpath + "/workflow/sendActor/openSendTaskCommunicationDailog/?wiid=" + Object.toQueryString("wiid") +
		"&taskId=" + Object.toQueryString("taskId");
	var parm = {};
	FUI.dialog(url, "完成沟通", parm, 760, 500, function(objectData, index) {
		var opinion = objectData.opinion;
		var actorJson = objectData.actorJson;
		var alermMsg = actorJson == "" ? "您确定完成沟通提交？" : "您确定继续传递到下一位沟通用户？";
		if (opinion == "") {
			FUI.Window.showMsg("请填写沟通意见");
		} else {
			FUI.Window.confirm(alermMsg, "温馨提示", function(index) {
				saveTaskCommunicationSubmit(opinion, actorJson);
			});
		}
		return false;
	}, false, {
		btnAlign: 'c',
		fit: false
	}, {
		sure: {
			"text": "提交完成沟通"
		}
	});
	return false;
}

//提交完成沟通
function saveTaskCommunicationSubmit(opinion, actorJson) {
	//保存 先保存工作流，再保存表单，如果是未有实例的情况下保存为草稿，且保存完跳转页面
	var dataJsonParm = {};
	dataJsonParm.taskId = WFContext.TaskId;
	dataJsonParm.opinion = opinion;
	dataJsonParm.actorJson = actorJson;
	var method = "sendCompletedTaskCommunication";
	if (actorJson != "") {
		method = "sendToNextTaskCommunication";
	}
	Object.toAjaxJson(workflowformSender, method, dataJsonParm, true, null, function(mssg) {
		if (mssg === false) return false;
		if (mssg.success) {
			if (window.opener != null) {
				try {
					//如果有自定义的方法调用业务表单自定义刷新父窗口的方法
					if (typeof customRefreshOpenerWindow == "function") {
						customRefreshOpenerWindow.call(this);

					} else {
						window.opener.window.refreshTargetGrid("grid");

					}
				} catch (err) {
					console.info(err);
				}
			}
			FUI.Window.showMsg(mssg.msg, null, 1, function() {
				if (window.opener != null) {
					window.close();
				} else {
					FUI.Window.closeEdit(true, 'grid');
				}
			});
		} else {

			alert(mssg.msg);
		}
	});
	// WF.Workflowform.submitWorkflowform(workflowformSender, method, null, dataJsonParm, null, null, function (mssg) {
	//     Object.toCloseLoading();
	//
	// });
	return false;
};

//**************************************************


function $collectParmsUsers() {
	return null;
	//在这里写收集用户的代码
	//var users=[{"value":"admin","text":"系统管理员"},{"value":"admintest","text":"test"}];
	//return users
}
